﻿using System;
using System.Diagnostics.Contracts;
using System.Reflection;

namespace OpenCube.Nbt.Mapping.Attributes
{
	[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
	public class NbtConverterAttribute
		: NbtAttribute
	{
		private readonly Type _typeConverterType;

		public NbtConverterAttribute(Type typeConverterType)
		{
			Contract.Requires<ArgumentNullException>(typeConverterType != null);
			Contract.Requires<ArgumentException>(typeof(INbtTypeConverter).GetTypeInfo().IsAssignableFrom(typeConverterType.GetTypeInfo()), "Convert should implement INbtTypeConverter");

			_typeConverterType = typeConverterType;
		}

		/// <summary>
		/// Gets the type of the convert.
		/// </summary>
		public Type ConverterType { get { return _typeConverterType; } }
	}
}
